﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace VIP.Infrastructure
{
    public class ApiResponse<T>
    {
        public int Code { get; set; }

        public string Message { get; set; }

        public T Data { get; set; }
    }
    public class ApiRes
    {
        public static async Task<ApiResponse<T>> OKAsync<T>(Task<T> data)
        {
            var rev = new ApiResponse<T>
            {
                Data = await data
            };
            return rev;
        }

        public static ApiResponse<T> OK<T>(T data)
        {

            var rev = new ApiResponse<T>
            {
                Data = data
            };
            return rev;
        }

        public static async Task<ApiResponse<bool>> Error(string msg, int code = -1)
        {

            await Task.CompletedTask;

            var rev = new ApiResponse<bool>
            {
                Data = false,
                Code = code,
                Message = msg
            };

            return rev;

        }
    }
}
